#ifndef __GAF_BUNDLE_H__
#define __GAF_BUNDLE_H__

namespace GAF
{
	//class Container -* ForEach
		class Bundle;
}
typedef GAF::Bundle			GAF_CBundle;

#include "GAF_Define.h"
#include "GAF_Container.h"

namespace GAF
{
	/// 数据集合类
	class Bundle : public Container
	{
	public:
		enum VarType
		{
			VAR_UNKOWN	= 0,
			VAR_BOOLEAN,		// b
			VAR_INTEGER,		// i
			VAR_LONG,		// l
			VAR_FLORT,		// f
			VAR_DOUBLE,		// d
			VAR_CHARS,		// c
			VAR_STRING,		// s
			VAR_POINTER,		// p
			VAR_AGENT,		// a
		};

	private:
		struct Var
		{
			Pointer		pVar;
			VarType		type;
		};

		typedef std::map<STD_STRING, Var>
					VarMap;

	public:
		Bundle();
		Bundle(const Bundle& bdlScr);
		~Bundle();

	public:
		Pointer			Foreach(bool bFirst);
		UINT			GetCount();
		void			Clear();

	public:
		void			operator=(const Bundle& bdlSrc);
		Bundle			operator+(const Bundle& bdlSrc);
		void			operator+=(const Bundle& bdlSrc);
		bool			operator==(Bundle& bdlOther);
		bool			operator!=(Bundle& bdlOther);

	public:
		bool			PutBoolean(STD_STRING strKey, bool b);
		bool			PutInteger(STD_STRING strKey, int n);
		bool			PutLong(STD_STRING strKey, long l);
		bool			PutFloat(STD_STRING strKey, float f);
		bool			PutDouble(STD_STRING strKey, double d);
		bool			PutChars(STD_STRING strKey, char* sz);
		bool			PutString(STD_STRING strKey, STD_STRING str);
		bool			PutPointer(STD_STRING strKey, Pointer p);
		bool			PutAgent(STD_STRING strKey, Agent a);

		bool			GetBoolean(STD_STRING strKey);
		int			GetInteger(STD_STRING strKey);
		long			GetLong(STD_STRING strKey);
		float			GetFloat(STD_STRING strKey);
		double			GetDouble(STD_STRING strKey);
		char*			GetChars(STD_STRING strKey);
		STD_STRING		GetString(STD_STRING strKey);
		Pointer			GetPointer(STD_STRING strKey);
		Agent			GetAgent(STD_STRING strKey);

	public:
		VarType			GetType(STD_STRING strKey);
		bool			Copy(const Bundle* pbdlSrc);

	private:
		Var&			FindArg(STD_STRING strKey);
		bool			PutArg(STD_STRING strKey, Pointer pArg, VarType kind);
		bool			ChangeArg(STD_STRING strKey, Pointer pArg, VarType kind);

	private:
		VarMap			m_mapArgs;
		VarMap::iterator	m_itForeach;
		Var			m_ArgTemp;
	};
}

#endif
